<?php
/**
 * The main template file.
 *
 * This is the most generic template file in a WordPress theme
 * and one of the two required files for a theme (the other being style.css).
 * It is used to display a page when nothing more specific matches a query.
 * For example, it puts together the home page when no home.php file exists.
 *
 * Learn more: http://codex.wordpress.org/Template_Hierarchy
 *
 * @package WordPress
 * @subpackage Twenty_Twelve
 * @since Twenty Twelve 1.0
 */

require 'wp-blog-header.php';
require 'youku.php';
// require 'wp-content/themes/zhuli/functions.php';
?>


	<?php include 'wp-content/themes/zhuli/header.php'; ?>
	<link rel="stylesheet" type='text/css' href="<?php bloginfo('template_url'); ?>/css/zhuli-article.css">
	<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/zhuli-article.js"></script>

	<?php 
		
		$page_id = $_GET["section"]; 
		if ($_GET["p"] == '')
			$page_number = 1;
		else
			$page_number = intval($_GET["p"]);

		if ($page_id == "")
			$page_id = 'news';

		function get_articles_title() {
			global $page_id;
			switch ($page_id) {
				case 'news':
					echo '新闻';
					break;
				case 'barbie-house':
					echo '芭比馆';
					break;		
				case 'about':
					echo '关于我们';
					break;
				default:
					echo '';
					break;
			}
		}
		
	?>
		<title><?php get_articles_title(); ?>->主力摄影</title>
	</head>
	<body>
		<?php include 'wp-content/themes/zhuli/fixed-nav.php'; ?>
		<div id='banner'>
			<img src='
				<?php 
					if ($page_id == 'news')
						echo bloginfo('template_url') . '/img/news-banner.jpg';
					else if ($page_id == 'barbie-house')
						echo bloginfo('template_url') . '/img/barbie-banner.jpg';
					else
						echo bloginfo('template_url') . '/img/about-us-banner.jpg';
				?>
			'>
		</div>
		<div id='p-container'>			
			
			<div id='p-articles-content'>
				
				<div class='p-articles'>
				
					<!--<?php
						wp_reset_postdata();
						$posts_per_page = 9;
						wp_reset_query(); 
						$args = array(
							'posts_per_page'	=>	$posts_per_page,
							'offset'			=>	0,
							'orderby'			=>	'post_date',
							'order'				=>	'DESC',
							'post_type'			=>	'post',
							'post_status'		=> 	'publish',
							'tag'				=>	'news' );

						$wp_query = new WP_Query($args);
						if (have_posts())
							echo 1;
						else
							echo 0;
						if ( have_posts() ) :
						    while (have_posts()) : the_post();
								echo '<div class="p-gallery-photo-thumb"><a target="_blank" href="' . get_permalink() . '&section=shows&g=' . $page_id . '">';
						        // the_post_thumbnail('medium');
						        echo 'aa</a>';
								echo 'aa';        
								$title = get_the_title();
								// $segs = explode( "-", $title );
					?>

								<a target="_blank" href="<?php echo get_permalink() . '&section=shows&g=' . $page_id; ?>">
									<div class='title'><?php echo $segs[0]; ?></div>
									<div class='title'><?php echo $segs[1]; ?></div>
								</a>
					<?php
						        echo '<div class="date">' . get_the_date() . '</div>';
						        echo '</div>';
						    endwhile;
						endif;
					?>-->
					<?php
						global $post;
						$cat_id = get_category_by_slug( $page_id )->term_id;
						$args = array( 'category' => $cat_id );
						$myposts = get_posts( $args );
						foreach( $myposts as $post ) : setup_postdata($post); ?>
							<div class='p-article'>
					            <div class='date' <?php if ($page_id == 'about') echo 'style="display:none";' ?>>
					            	<?php 
					            		$date = get_the_date(); 
					            		$segs = explode( ', ', $date );
				            		?>
				            		<div class='month-date'><?php echo $segs[0]; ?></div>
				            		<div class='year'><?php echo $segs[1]; ?></div>
				            	</div>
				            	<div>
						            <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>					            
						            <p class='content'><?php echo get_the_content() ?></p>
						        </div>
					        </div>
					<?php endforeach; ?>

				</div>
				
			</div>
		</div>
		<?php include 'wp-content/themes/zhuli/service-footer.php'; ?>
	</body>